<PageHeader as |p|>
  <p.top>
    {{key-value-header
      baseKey=(hash id=model.id)
      path="vault.cluster.secrets.backend.list"
      mode="show"
      root=(hash
        label=model.engineId
        text=model.engineId
        path="vault.cluster.secrets.backend.list-root"
        model=model.engineId
      )
      showCurrent=true
    }}
  </p.top>
  <p.levelLeft>
    <h1 class="title is-3">
      Version History
    </h1>
  </p.levelLeft>
</PageHeader>
<ListView @items={{reverse model.versions}} @itemNoun="version" as |list|>
  <ListItem @hasMenu={{false}} @linkParams={{array 'vault.cluster.secrets.backend.show' model.id (query-params version=list.item.version) }} as |Item|>
    <Item.content>
      <div class="columns is-flex-1">
        <div class="column is-one-third">
          <Icon @glyph="file-outline" class="has-text-grey" />Version {{list.item.version}}
          {{#if (eq list.item.version model.currentVersion)}}
            <span class="has-text-success is-size-9">
              <Icon @glyph="check-circle-outline" />Current
            </span>
          {{/if}}
        </div>
        <div class="column">
          {{#if list.item.deleted}}
            <span class="has-text-grey is-size-8">
              <Icon @glyph="cancel-square-outline" />Deleted
            </span>
          {{/if}}
          {{#if list.item.destroyed}}
            <span class="has-text-danger is-size-8">
              <Icon @glyph="cancel-square-outline" />Destroyed
            </span>
          {{/if}}
        </div>
      </div>
    </Item.content>
    <Item.menu>
      <SecretVersionMenu @version={{list.item}} @useDefaultTrigger={{true}}>
        <li class="action">
          <SecretLink
            @mode="show"
            @secret={{model.id}}
            @class="has-text-black has-text-weight-semibold"
            @queryParams={{query-params version=list.item.version}}
          >
            View version {{list.item.version}}
          </SecretLink>
        </li>
        <li class="action">
          <SecretLink
            @mode="edit"
            @secret={{model.id}}
            @class="has-text-black has-text-weight-semibold"
            @queryParams={{query-params version=list.item.version}}
          >
            Create new version from {{list.item.version}}
          </SecretLink>
        </li>
      </SecretVersionMenu>
    </Item.menu>
  </ListItem>
</ListView>
